# 元组
# t1 = (12,3,4,5,70)
# t2 = 'java','python','mysql'
# t3 = (20,30,40,(2,3,90))
# t4 = (100,)
# print(t1)
# print(t2)
# print(t3)
# print(t4)

# t1 = (12,3,4,5,70)
# t4 = (100,)
#
# t = t1+t4
# print(t)

# 索引
# t1 = (12,3,4,5,70)
# print(t1[1])
# 默认下标从1开始

# 遍历
# t1 = (12,3,4,5,70)
# for i in range(0, len(t1)):
#     print(t1[i], end=" ")

# 使用生成器对象__next__遍历
# # 首先，定义一个生成器函数
# def my_generator():
#     for i in range(5):
#         yield i * 2
# # 然后，创建生成器对象并使用 __next__() 方法进行遍历：
# # 创建生成器对象
# gen = my_generator()
#
# # 使用 __next__() 遍历
# for i in range(5):
#     value = gen.__next__()
#     print(value, end=" ")

# 统计英语句子的词频
# sentence="Beauiful is better than ugly. Explicit is better than implicit.\
# Simple is better than complex.Complex is better then complicated"
#
# for ch in ",.?!": #将文本涉及的标点符号用空格替换
#     sentence=sentence.replace(ch, " ")
# words=sentence.split() # words是句子中的单词
# # 使用字典统计词频
# # map是一个键值对<key, value>，key表示单词，value表示出现的次数
# map={}
# for word in words:
#     if word in map: # 如果单词已经在字典里了，自增1
#         map[word]+=1
#     else: # 否则就是刚刚出现
#         map[word]=1
# e=list(map.items())
# print(e)

# 已知两个3行3列的矩阵，实现其对应位置的数据相加，并返回一个产析矩阵
x = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]
y = [[10, 11, 12], [13, 14, 15], [16, 17, 18]]
res=[[0, 0, 0], [0, 0, 0], [0, 0, 0]]
for i in range(len(x)):
    for j in range(len(x[0])): # 循环控制列
        res[i][j] = x[i][j] + y[i][j]

for r in res:
    print(r)